package com.example.lyqwork.pojo;

import jakarta.persistence.*;

import java.util.HashMap;
import java.util.Map;

@Table(name = "tb_order")
@Entity
public class CarOrder {
    // 初始化固定的 Map
    private static final Map<String, String> planDataMap = new HashMap<>();

    static {
        planDataMap.put("planA", "身份证,信用卡,行车记录,绿本");
        planDataMap.put("planB", "身份证,信用卡,行车记录,");
        // 可以继续添加其他计划和对应的 dataStr
    }

    public CarOrder() {
    }

    public CarOrder(String customerName, String planName,Integer userId) {
        this.customerName = customerName;
        this.planName = planName;
        this.userId = userId;
        // 使用 planName 从固定的 Map 中获取 dataStr
        this.dataStr = planDataMap.get(planName);
        int len  = dataStr.split(",").length;
        this.dataStatus = "";

        for (int i = 0; i < len; i++){
            this.dataStatus += "0,";
        }
    }

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "order_id")
    private Integer orderId;

    @Column(name = "user_id")
    private Integer userId;

    @Column(name = "customer_name")
    private String customerName;

    @Column(name = "plan_name")
    private String planName;

    @Column(name = "data_str")
    private String dataStr;

    @Column(name = "data_status")
    private String dataStatus;


    public Integer getOrderId() {
        return orderId;
    }

    public String getDataStatus() {
        return dataStatus;
    }

    public void setDataStatus(String dataStatus) {
        this.dataStatus = dataStatus;
    }

    public void setOrderId(Integer orderId) {
        this.orderId = orderId;
    }

    public Integer getUserId() {
        return userId;
    }

    public void setUserId(Integer userId) {
        this.userId = userId;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }

    public String getPlanName() {
        return planName;
    }

    public void setPlanName(String planName) {
        this.planName = planName;
    }

    public String getDataStr() {
        return dataStr;
    }

    public void setDataStr(String dataStr) {
        this.dataStr = dataStr;
    }

    @Override
    public String toString() {
        return "CarOrder{" +
                "orderId=" + orderId +
                ", userId=" + userId +
                ", customerName='" + customerName + '\'' +
                ", planName='" + planName + '\'' +
                ", dataStr='" + dataStr + '\'' +
                ", dataStatus='" + dataStatus + '\'' +
                '}';
    }
}
